package com.threeti.jiayusms.interfaces.ws.communicationmessage;

import static org.springframework.util.CollectionUtils.isEmpty;

import java.util.List;

import javax.jws.WebService;

import org.springframework.beans.factory.annotation.Autowired;

import com.threeti.jiayusms.domain.model.CommunicationMessage;
import com.threeti.jiayusms.domain.model.CommunicationRule;
import com.threeti.jiayusms.domain.model.CommunicationTime;
import com.threeti.jiayusms.domain.model.legacy.Condition;
import com.threeti.jiayusms.domain.model.legacy.ConditionType;
import com.threeti.jiayusms.domain.model.legacy.Node;
import com.threeti.jiayusms.domain.model.legacy.ProductType;
import com.threeti.jiayusms.domain.service.communicationmessage.CommunicationMessageQueryService;
import com.threeti.jiayusms.domain.service.communicationrule.CommunicationRuleQueryService;
import com.threeti.jiayusms.domain.service.communicationtime.CommunicationTimeQueryService;
import com.threeti.jiayusms.domain.service.communicationvoice.CommunicationVoiceQueryService;
import com.threeti.jiayusms.domain.service.legacy.JiaYuDBLegacyQueryService;
import com.threeti.jiayusms.interfaces.facade.JiaYuSystemQueryFacade;


@WebService(serviceName = "MessageTemplateService", portName = "MessageTemplateServicePort",
		endpointInterface = "com.threeti.jiayusms.interfaces.ws.communicationmessage.MessageTemplateWebService",
		targetNamespace = "http://127.0.0.1:8080/sms-maintenance-main" )
public class MessageTemplateWebServiceDelegate implements MessageTemplateWebService {

  @Autowired
  private JiaYuSystemQueryFacade queryFacade;


	//@Override
//	public CommunicationMessageDto findCommunicationMessageBy(String messageId) {
//		CommunicationMessage msgTemplate = queryService.findCommunicationMessageBy(messageId);
//
//		CommunicationMessageDto dto = new CommunicationMessageDto(
//				msgTemplate.getSmsLevel(),msgTemplate.getSmsContent(),
//				msgTemplate.getSmsDescription(),msgTemplate.getSmsType(),
//				msgTemplate.getFeedbackValue(),msgTemplate.getActiveFlag());
//
//		return dto;
//	}

	//@Override
//	public List<CommunicationMessageDto> findCommunicationMessageByList(){
//		List<CommunicationMessageDto> dtoList = new ArrayList<CommunicationMessageDto>();
//
//		List<CommunicationMessage> list = new ArrayList<CommunicationMessage>();
//
//		for (CommunicationMessage msgTemplate : list) {
//			CommunicationMessageDto CommunicationMessageDto = new CommunicationMessageDto(
//					msgTemplate.getSmsLevel(),msgTemplate.getSmsContent(),
//					msgTemplate.getSmsDescription(),msgTemplate.getSmsType(),
//					msgTemplate.getFeedbackValue(),msgTemplate.getActiveFlag());
//			dtoList.add(CommunicationMessageDto);
//		}
//
//		return dtoList;
//	}

  @Override
  public String getMessageBy(String orderid, String msgTemplateId, String sendTimeId) {
    return queryFacade.getMessageTemplateBy(orderid, msgTemplateId, sendTimeId);
  }


  @Override
  public String getMessagePreviewBy(String nodeCode,
                                    String msgTemplateId,
                                    String ruleTemplateId,
                                    String timeTemplateId,
                                    String productTypeCode,
                                    String conditionTypeCode,
                                    String conditionCode,
                                    String communicationEnable) {
    return queryFacade.getMessagePreviewBy(nodeCode, msgTemplateId, ruleTemplateId, timeTemplateId, 
        productTypeCode, conditionTypeCode, conditionCode, communicationEnable);
  }
}
